package vetAdmin.swing;

import java.awt.EventQueue;

import javax.swing.JDesktopPane;
import javax.swing.JDialog;
import javax.swing.JInternalFrame;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JTabbedPane;
import javax.swing.border.TitledBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.JTextPane;
import javax.swing.JButton;

public class FichaFrame extends JInternalFrame {
	
	private JPanel infoPanel;	
	private JTabbedPane tabsPanel;
	private JPanel historiaClinicaPanel;
	private JPanel vacunasPanel;
	private JPanel anticPanel;
	private JTextPane textPane;
	private JButton btnNuevo;
	private HistoriaClinicaDialog historiaDialog;
	private String[] contenidoHistoria;
	private JTextArea nuevoIngreso;

	public FichaFrame() {
		
		setClosable(true);
        initComponents();	
	}
	

	private void initComponents() {
		
		infoPanel = new JPanel();
		historiaClinicaPanel = new JPanel();
		vacunasPanel = new JPanel();
		anticPanel = new JPanel();		
		btnNuevo = new JButton("Nuevo");
		textPane = new JTextPane();
		historiaDialog = new HistoriaClinicaDialog();
		contenidoHistoria = new String[4];
		nuevoIngreso = new JTextArea();
		
		
		infoPanel.setBorder(new TitledBorder(null, "Paciente", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		
		tabsPanel = new JTabbedPane(JTabbedPane.TOP);
		tabsPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));		
		
		tabsPanel.addTab("Historia Clinica", historiaClinicaPanel);
		
		
		textPane.setEditable(false);
		
	
		GroupLayout gl_historiaClinicaPanel = new GroupLayout(historiaClinicaPanel);
		gl_historiaClinicaPanel.setHorizontalGroup(
			gl_historiaClinicaPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_historiaClinicaPanel.createSequentialGroup()
					.addContainerGap()
					.addComponent(textPane, GroupLayout.PREFERRED_SIZE, 304, GroupLayout.PREFERRED_SIZE)
					.addContainerGap())
		);
		gl_historiaClinicaPanel.setVerticalGroup(
			gl_historiaClinicaPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_historiaClinicaPanel.createSequentialGroup()
					.addGap(5)
					.addComponent(textPane, GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
					.addContainerGap())
		);
		historiaClinicaPanel.setLayout(gl_historiaClinicaPanel);
		
		tabsPanel.addTab("Vacunas", vacunasPanel);
		tabsPanel.addTab("Anticonceptivos", anticPanel);
	
		setBounds(100, 100, 538, 374);
	
		
		GroupLayout groupLayout = new GroupLayout(getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addComponent(infoPanel, GroupLayout.PREFERRED_SIZE, 169, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(btnNuevo)
						.addComponent(tabsPanel, GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE))
					.addContainerGap())
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING, false)
						.addComponent(infoPanel, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
						.addComponent(tabsPanel, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addComponent(btnNuevo)
					.addContainerGap(39, Short.MAX_VALUE))
		);
		getContentPane().setLayout(groupLayout);
		
		btnNuevo.addActionListener(new java.awt.event.ActionListener() {            
        	
	        public void actionPerformed(java.awt.event.ActionEvent evt) {
	            
	        	historiaDialog.setVisible(true);
	        	       
	        }
		
		
		
		});

		
	}
	
	
	
	
	
	
	
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					
					FichaFrame fichaFrame = new FichaFrame();
					fichaFrame.setVisible(true);					
            		JDesktopPane jDesktop = new JDesktopPane();
                	jDesktop.add(fichaFrame);
					
					
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
}
